package com.eystar.ext.kit.tree;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.annotation.JSONField;

public class BaseTree implements Serializable {

	private static final long serialVersionUID = -9189631784252440402L;
	private String id;// 节点id
	@JSONField(name="pid")
	private String parentId;// 节点父id
	@JSONField(name="text")
	private String nodeName;
	private Map<String, Object> attrs = new HashMap<String, Object>();
	private List<BaseTree> children;// 孩子节点

	public BaseTree() {

	}

	public BaseTree(String id, String parentId,String nodeName) {
		this.id = id;
		this.parentId = parentId;
		this.nodeName = nodeName;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getNodeName() {
		return nodeName;
	}

	public void setNodeName(String nodeName) {
		this.nodeName = nodeName;
	}

	public List<BaseTree> getChildren() {
		return children;
	}

	public void setChildren(List<BaseTree> children) {
		this.children = children;
	}

	public Map<String, Object> getAttrs() {
		return attrs;
	}

	public void setAttrs(Map<String, Object> attrs) {
		this.attrs = attrs;
	}
	
	public void putAttr(String key,Object value){
		attrs.put(key, value);
	}

	@SuppressWarnings("unchecked")
	public <T> T getAttr(String key){
		return (T) attrs.get(key);
	}
}